#include<bits/stdc++.h>
#define int long long
using namespace std;
#define getchar() (p1 == p2 && (p2 = (p1 = buf1) + fread(buf1, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf1[1 << 23], *p1 = buf1, *p2 = buf1, ubuf[1 << 23], *u = ubuf;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],to,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++to]=48+x%10;while(to) pc(stk[to--]);}
}
using namespace IO;
const int N = 5e5+10,mod = 1e9+7;
int n,k,x,y,head[N],dep[N],v[N],fa[N],g[N],f[N],sum,sum1,cnt,l,r,ans;
struct w
{
	int to,nxt;
}b[N<<1];
inline void add(int x,int y)
{
	b[++cnt].nxt = head[x];
	b[cnt].to = y;
	head[x] = cnt;
}
void dfs1(int x,int y)
{
	fa[x] = y; dep[x] = dep[y]+1;
	for(int i = head[x];i;i = b[i].nxt)
		if(b[i].to != y)
			dfs1(b[i].to,x);
}
void dfs(int x)
{
	if(x > n)
	{
		for(int i = 1;i <= n;i++)
			for(int j = i;j <= n;j++)
			{
				l = i,r = j; sum = 0,sum1 = 0;
				while(dep[l] > dep[r]) sum++,sum1 += v[l],l = fa[l];
				while(dep[r] > dep[l]) sum++,sum1 += v[r],r = fa[r];
				while(l != r)
				{
					sum++,sum1 += v[l],sum++,sum1 += v[r];
					l = fa[l],r = fa[r];
				}
				sum++,sum1 += v[l];
				if(sum == k && sum1 != 1) return;
			}
		ans++;
		return;
	}
	v[x] = 0,dfs(x+1);
	v[x] = 1,dfs(x+1);
}
signed main()
{
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	read(n),read(k);
	for(int i = 1;i < n;i++) read(x),read(y),add(x,y),add(y,x),v[x]++,v[y]++;
	for(int i = 1;i <= n;i++) sum += (v[i] == 1);
	if(sum == 2)
	{
		pc('Y'),pc('E'),pc('S'),pc('\n');
		print(k); flush();
		return 0;
	}
	if(n <= 18)
	{
		for(int i = 1;i <= n;i++) v[i] = 0;
		dfs1(1,0),dfs(1);
		if(ans) pc('Y'),pc('E'),pc('S'),pc('\n');
		else pc('N'),pc('O'),pc('\n'); 
		print(ans); flush();
	}
	return 0;
}
